<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<html>
<head>
    <title>登录页</title>
    <%--echart线图、柱状图、饼图等各种图型库 cdn--%>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.3/echarts.min.js"></script>
    <%--jquery cdn--%>
    <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>
</head>
<body>

<form action="list.do" method="get">

    姓名/编号  <input name="nameOrNum"  value="${query.nameOrNum}"><br>
    职位<select name="postId">
    <option value="">请选择</option>
    <c:forEach items="${postList}" var="p">
        <option  ${query.postId==p.id ? 'selected':''}  value="${p.id}">${p.name}</option>
    </c:forEach>
</select><br>
    院校<select name="schoolId">
    <option value="">请选择</option>
    <option value="">请选择</option>
    <c:forEach items="${schoolList}" var="s">
        <option  ${query.schoolId==s.id ? 'selected':''}  value="${s.id}">${s.name}</option>
    </c:forEach>
</select><br>
    部门<select name="deptId">
    <option value="">请选择</option>
    <option value="">请选择</option>
    <c:forEach items="${deptList}" var="d">
        <option  ${query.deptId==d.id ? 'selected':''}  value="${d.id}">${d.name}</option>
    </c:forEach>
</select><br>
    创建时间 <input type="date" name="createStartTime" value="${query.createStartTime}" > - <input type="date" name="createEndTime"  value="${query.createEndTime}"> <br>

    <input type="submit" value="查询">
    <input type="button"  onclick="batchDel()" value="批量删除"><br> <a href="addPage.do">添加</a>
    <table>
    <tr>
        <td> </td>
        <td>id</td>
        <td>头像/姓名</td>
        <td>编号</td>
        <td>职位</td>
        <td>部门</td>
        <td>院校</td>
        <td>开始时间</td>
        <td>结束时间</td>
        <td>创建时间</td>
        <td>操作</td>
    </tr>

        <c:forEach items="${pageInfo.list}" var="l">
            <tr>
                <td><input type="checkbox" name="delId" value="${l.id}"></td>
                <td>${l.id}</td>
                <td> <img src="${l.avatar}">    ${l.name}</td>
                <td>${l.num}</td>
                <td>${l.postName}</td>
                <td>${l.deptName}</td>
                <td>${l.schoolName}</td>
                <td>${l.startTime}</td>
                <td>${l.endTime}</td>
                <td>${l.createTime}</td>
                <td><a href="del.do?id=${l.id}">删除</a></td>
            </tr>
        </c:forEach>
    </table>
</form>


<script>
    function batchDel() {
        var id = []

        $('[name=delId]:checked').each(function () {
            let value = this.value;
            id.push(value)
        })

        if (id.length == 0){
            alert("请选择一条数据")
            return
        }

        location.href = 'del.do?id=' + id

    }
</script>

</body>
</html>